package com.blue.http.controller;

import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import com.blue.http.message.HttpRequest;
import com.blue.http.message.UploadFile;

//@Component
//@Http(url="/upload", method=HttpMethod.POST)
public class UploadController
{
	public UploadController()
	{
	}
	
	public String upload(HttpRequest request)
	{
		JSONObject object = new JSONObject();
		
		JSONObject content = new JSONObject();
		object.put("string", content);
		Map<String, String> contentMap = request.getPostMap();
		for (Map.Entry<String, String> entry : contentMap.entrySet())
		{
			content.put(entry.getKey(), entry.getValue());
		}
		
		JSONObject file = new JSONObject();
		object.put("file", file);
		Map<String, UploadFile> fileMap = request.getFileMap();
		for (Map.Entry<String, UploadFile> entry : fileMap.entrySet())
		{
			file.put(entry.getKey(), entry.getValue().toString());
		}
		
		return object.toJSONString();
	}
	
}
